package action;

import java.util.HashMap;
import java.util.List;

import model.Module;
import model.ModuleCheck;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Controller;

import service.ModuleService;
import action.base.BaseAction;

@Controller
@Scope("prototype")
public class ModuleAction extends BaseAction {
	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	@Autowired
	private ModuleService moduleService;
	private Boolean success = false;

	private List<HashMap<String, Object>> list;
	private List<Module> moduleList;
	private List<ModuleCheck> moduleCheckList;
	private Module module;

	/**
	 * 模块管理列表 的 树形结构
	 * 
	 * @return
	 */
	public String queryTree() {
		Integer id = super.getParameterInt("node");
		setList(moduleService.queryTree(id));

		return "list";
	}

	/**
	 * 模块管理新增，修改选项框 的 树形结构
	 * 
	 * @return
	 */
	public String getTreeBypid() {

		setModuleList(moduleService.getTreeBypid(0));
		return "moduleList";
	}

	/**
	 * 模块管理新增，修改选项框 的 树形结构
	 * 
	 * @return
	 */
	public String getTreeCheckBypid() {

		moduleCheckList = moduleService.getTreeCheckBypid(0);
		return "moduleCheckList";
	}

	/**
	 * 模块新增、修改
	 * 
	 * @param user
	 * @return
	 */
	public String saveOrUpdate() {
		moduleService.saveOrUpdate(module);
		success = true;
		return "success";
	}

	public Boolean getSuccess() {
		return success;
	}

	public void setSuccess(Boolean success) {
		this.success = success;
	}

	public List<HashMap<String, Object>> getList() {
		return list;
	}

	public void setList(List<HashMap<String, Object>> list) {
		this.list = list;
	}

	public List<Module> getModuleList() {
		return moduleList;
	}

	public void setModuleList(List<Module> moduleList) {
		this.moduleList = moduleList;
	}

	public Module getModule() {
		return module;
	}

	public void setModule(Module module) {
		this.module = module;
	}

	public List<ModuleCheck> getModuleCheckList() {
		return moduleCheckList;
	}

	public void setModuleCheckList(List<ModuleCheck> moduleCheckList) {
		this.moduleCheckList = moduleCheckList;
	}

}
